package com.leokok.jts.learning.jts.core.densifier;

import org.junit.Before;
import org.junit.Test;
import org.locationtech.jts.densify.Densifier;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.GeometryFactory;
import org.locationtech.jts.geom.PrecisionModel;
import org.locationtech.jts.io.ParseException;
import org.locationtech.jts.io.WKTReader;

public class DensifierTest {

    GeometryFactory geometryFactory;

    @Before
    public void before(){
        PrecisionModel precisionModel = new PrecisionModel(1000);
        geometryFactory = new GeometryFactory(precisionModel);
    }

    @Test
    public void densifier() throws ParseException {
        WKTReader wktReader = new WKTReader();
        Geometry geometry = wktReader.read("LINESTRING (115.9875 31.9967, 116.119 32.033)");

        Geometry geometry2 = geometryFactory.createGeometry(geometry);
        System.out.println(geometry2.toText());

        Geometry geometry1 = Densifier.densify(geometry2,0.05);
        System.out.println(geometry1.toText());
    }
}
